<extend name="Index:base" />
<block name="title"><title>店铺管理</title></block>
<block name="style">
 <style>
.main,.panel-default>.panel-heading{
background:none;
}
body{
background:none;
}
.panel.panel-default,.panel .panel-body,.panel .panel-heading,.table-bordered {
	border:none;
}
.table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
	border:none;		
	padding:15px;	
	line-height:8px;
	height: 8px;
	border-top: 1px solid #d4d4d4;
	border-bottom: 1px solid #d4d4d4;
}
.name strong{
color:#000000;
font-size:15px;
font-weight:600;
}
.name {
	color:#20a8d8;
	font-size:12px;
}
.smallfont {
	color:#9c9c9c;
	font-size:12px;
}

.align-center{
	text-align:center; 
}
.title2{
text-align:center;
}
.table-bordered > tbody > tr .wd{
	text-align:left;	
}

.col-xs-2,.col-xs-4{
padding-right:0;
margin:10px 0;
}
.col-sm-3{
width:10%;
}
.col-sm-2{
width:8%;
}
.col-sm-1{
width:5%;
}
.col-sm-4{
width:18%;
}
.col-sm-1,.col-sm-2{
margin:16px 0;
}
.col-sm-3,.col-sm-4{
margin:10px 0;
}
.col-sm-1,.col-sm-2,.col-sm-3,.col-sm-4{
padding-right:0;
}
 </style>
</block>
	<!-- start: Header -->
<block name="body">

			<!-- end: Main Menu -->
						
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-life-bouy"></i>店铺管理</h3>
				</div>
			</div>

			<div class="row">		
				<div class="col-lg-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><span class="break"></span><strong>店铺管理</strong></h2>&nbsp;&nbsp;&nbsp;

							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-primary" href="{:U('Store/index')}?clear=1" id="add_right">强制刷新</i></a>
							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-default" href="{:U('Store/index')}?store_join=store_join" id="add_right">开店申请</i></a>							
							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-default" href="#" id="add_right">续签申请</i></a>
							&nbsp;&nbsp;&nbsp;
							<a class="btn btn-default" href="#" id="add_right">经营类目申请</i></a>
												
						</div>&nbsp;&nbsp;&nbsp;
						<ol class="breadcrumb" style="height:55px;background-color: #ffffff;">							
							<li><i class="fa fa-warning"></i><a href="#">操作提示：</a></li><br/>	
							<li><font style="font-size:8px;color:#888;">新增店铺操作时，当店主账号为已存在的会员账号，则该新增店铺为管理员通过后台帮助该会员开启店铺功能，该新店铺为该会员所有！</font></li>							
						</ol>
						<div class="panel-body">
							<!--搜索 开始-->
							<form method="get" name="formSearch" id="formSearch">
							
				               <div class="col-md-12" style="background-color:#f5f5f5;padding:0;">
								<div class="form-group" style="width:100%;">
				                    
									<label class="col-sm-2 control-label" for="input-small">所属等级</label>
									<div class="col-sm-3">
										<select name="grade_id" class="form-control">
											<option value="">请选择...</option>
											<option value="0">系统默认</option>
											<option value="1">普通店铺</option>
											<option value="2">白金店铺</option>
											<option value="3">钻石店铺</option>
										</select>
				                    </div>
				                    
									<label class="col-sm-1 control-label" for="input-small">店主</label>
									<div class="col-sm-4">
				                        <input type="text" id="member_name" name="member_name" class="form-control" placeholder="">
				                    </div>
				                    
									<label class="col-sm-2 control-label" for="input-small">店铺类型</label>
									<div class="col-sm-3">
											<select name="store_type" class="form-control">
												<option value="">请选择...</option>
                                                <option value="open">开启</option>
												<option value="close">关闭</option>
												<option value="expire">即将到期</option>
												<option value="expired">已到期</option>
                                            </select>
				                    </div>
				                   
									<label class="col-sm-1 control-label" for="input-small">店铺</label>
									 <div class="col-sm-4">
									<input type="text" id="seller_name" name="seller_name" class="form-control" placeholder="">
				                    </div>
				                    <div class="col-sm-3">
										<button type="submit" class="btn btn-primary">搜索</button>
				                    </div>
				                </div>
				               </div>
				                    
							  </form>
							  <!--搜索 结束-->
							<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>ID</th>
                                      <th>店铺</th>
									  <th class="title2">店主账号</th>
									  <th class="title2">店主卖家账号</th>
									  <th class="title2">所属等级</th>
									  <th class="title2">有效期至</th>
									  <th class="title2">状态</th>
									  <th class="title2">操作</th>
								  </tr>
							  </thead>   
							  <tbody id="state">
								<foreach name="list" item="vo">
								<tr>
									<td>{$vo.store_id}</td>
									<td class="wd">
										{$vo.store_name}
									</td>
									 <td class="align-center">{$vo.member_name}</td>
									 <td class="align-center">{$vo.seller_name}</td>
									 
									<td class="align-center">
									<if condition="$vo.grade_id eq '1'">普通店铺</if>
									<if condition="$vo.grade_id eq '2'">白金店铺</if>
									<if condition="$vo.grade_id eq '3'">钻石店铺</if>									
									</td>
									<td class="align-center"><if condition="$vo.store_end_time eq ''">无限期<else/>{$vo.store_end_time|date='Y-m-d',###}</if></td>
									
									<td class="align-center">
									<if condition="$vo.store_state eq '0'"><font style="color:red;">关闭</font></if>
									<if condition="$vo.store_state eq '1'">开启</if>
									<if condition="$vo.store_state eq '2'"><font style="color:#0493c5;">审核中</font></if>									
									</td>
									<td class="align-center">
										<a href="/shop/show_store.html?stid={$vo.store_id}" target="_blank">					
										&nbsp;&nbsp;<span class="label label-success" >查看</span>
										</a>	
										<a class="label label-primary"  href="" >编辑</i>
										</a>
										
										<a href="#" data-id="{$vo.store_id}" data-type="edit">			
										&nbsp;&nbsp;
										<if condition="$vo.store_state eq '0'">
										<span class="label label-success" data-status="1" >开启</span>
										</if>
										<if condition="$vo.store_state eq '1'">
										<span class="label label-danger" data-status="0" >关闭</span>
										</if>
										</a>
										
										<a href="#" data-id="{$vo.store_id}">					
										&nbsp;&nbsp;<span class="label label-info" data-cash="1">经验类目</span>
										</a>
										<a href="#" data-id="{$vo.store_id}" data-type="del">					
										&nbsp;&nbsp;<span class="label label-danger">删除</span>
										</a>										
									 </td>

								</tr>
								</foreach>
							  </tbody>
						  </table>  
							<ul class="pagination">
								{$page}
							 </ul>						  
						</div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->				
			
		<!-- end: Content -->
		<br><br><br>
		
	</div><!--/container-->
		
</block>
<block name="script">
<script>


$("#state tr td a").click(function(){

    var id = $(this).attr('data-id');
	var state = $(this).find('span').attr('data-status');
	
	var type = $(this).attr('data-type');
	var username = $(this).attr('data-username');
	var mobile = $(this).attr('data-mobile');
	var realname = $(this).attr('data-realname');

	if (type=='del') {
		if(confirm("确定要删除吗？")){
			$.ajax({
				url:"{:U('Store/del')}",
				data:{id:id,table:3,str:'store_id'},
				type:'post',
				dataType:'json',
				success:function (e) {			
				//alert(id);
					alert(e.info); 
					location.reload();				
				}
			});	
		}else{
			//否
			return false;
		}
	}
	//alert(state);
	if (id && type=='edit') {
		if(confirm("确定要修改吗？")){
			$.ajax({
				url:"{:U('Store/edit')}",
				data:{id:id,table:3,state:state,str:'store_id'},
				type:'post',
				dataType:'json',
				success:function (e) {			
				//alert(e.info);
					if (e.info==1) {
						alert('开启成功');
						location.reload();
					}else if (e.info==2) {
						alert('关闭成功');
						location.reload();
					}else if(e.info==4){
						alert('操作失败');
					} 				
				}
			});		
		}else{
			//否
			return false;
		}	
	}  

});
</script>
</block>	









